﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TransCode.Logic;
using TransCode.Entitys;
using TransCodeTask;
using System.Threading;


namespace TransCodeService
{
    public class TransCodeServiceWorker
    {

        JobLogic jobdb = new JobLogic();

        private string serviceIp = ConfigValue.GetConfigByName("serviceIp");

        private List<Thread> _threads = new List<Thread>();

        public void running()
        {
            List<Job> jobs = jobdb.JobList().Where(it => it.State == 1 && it.Filename.Equals("test.mp4")).ToList();
            //List<Job> jobs = jobdb.JobList().Where(it => it.Server.IP == serviceIp).Where(it => it.State == 0).ToList();
            foreach (Job job in jobs)
            {             
               JobWorker worker = new JobWorker(jobdb); 
               Thread _thread = new Thread(new ParameterizedThreadStart(worker.running));
               _thread.Start(job);
               _threads.Add(_thread);
            }
        }

     
    }
}
